﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SysRouteLinq.Forms;
using System.Data.SqlClient;

namespace SysRouteLinq
{
    public partial class FormLogin : Form
    {
        public FormLogin()
        {
            InitializeComponent();
        }

        private SysRouteDataContext dc = new SysRouteDataContext();

        private void button1_Click(object sender, EventArgs e)
        {
            IEnumerable<Administrador> login = from l in dc.Administradors
                                       where l.matricula == textBox1.Text
                                       select l;
            if (login.Count() > 0 && login.Single().senha == textBox2.Text)
            {
                DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("Usuário ou senha inválidos");
                DialogResult = DialogResult.Cancel;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
  }

